/****************************************************** 
 *	Code by Utkarsh Sinha
 *	Based on JIFT by Jun Liu
 *	Visit http://aishack.in/ for more indepth articles and tutorials
 *	on artificial intelligence
 * Use, reuse, modify, hack, kick. Do whatever you want with
 * this code :)  ****
 ******************************************************/

#include "stdafx.h"
#include <vector>

#include "KeyPoint.h"

using namespace std;

	// verifica se os descritores deste KeyPoint tem equivalentes com distancias euclidianas aceitaveis
	int Keypoint::match(Keypoint other)
	{
		// tem q ter o mesmo numero de descritores
		if (orien.size() != other.orien.size()) return 1000;

		float medida; float threshold=0.1;

		for(int i=0;i<orien.size();i++)
		{
			// comparando na ordem

			float medida = descriptorEuclideanDistance(other.orien[i],orien[i],other.mag[i],mag[i]);

			if (medida > threshold){
				return false;
			};
		};

		return true;
	}

	// calcula a medida euclidiana entre os descritores (tetah1,m1) e (tetah2,m2)
	float Keypoint::descriptorEuclideanDistance(float tetah1,float tetah2,float m1,float m2)
	{
		float deltaOrient = tetah2 - tetah1;
		float deltaMag = m2 - m1;

		deltaMag =  deltaMag*deltaMag;
		deltaOrient = deltaOrient*deltaOrient;

		return 1;//ssqrt(deltaMag + deltaOrient);
	}
